package com.aio.kgo.simple.form.database.mysql.domain.dao;

import cn.hutool.core.convert.Convert;
import com.aio.kgo.simple.form.common.domain.save.ModelDefinitionDo;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;

/**
 * @author lizhenming
 * @desc: 流程模型定义DO
 * @date 2023/12/26 22:47
 */
@Data
@TableName("aio_model_definition")
public class ModelDo {
    private String id;
    private String modelName;
    private String modelKey;
    /**  所属模块  */
    private String module;

    private Integer modelStatus;

    private String remark;

    /**  多个值  */
    private Boolean multiValue;
    /**  布局  */
    private String layout;
    /**  字段定义  */
    private String modelDefinition;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    public ModelDefinitionDo getModelDef(){
        ModelDefinitionDo modelDefinitionDo = Convert.convert(ModelDefinitionDo.class,this);
        modelDefinitionDo.setModelDesign(JSON.parse(this.modelDefinition));
        return modelDefinitionDo;
    }
}
